package com.clusterswisdom.horn.api.tmall.action.scitem;

import com.alibaba.fastjson.JSONObject;
import com.clusterswisdom.horn.api.ioc.HornAction;
import com.clusterswisdom.horn.api.ioc.HornResponse;
import com.clusterswisdom.horn.api.ioc.api.ApiConfig;
import com.clusterswisdom.horn.api.tmall.action.AbstractTmallAction;
import com.clusterswisdom.horn.api.tmall.action.scitem.ThreadOfStore.KeepToDb;

public class UpdateAreaStockForWarningAction extends AbstractTmallAction implements HornAction{
	@Override
	public HornResponse execute(ApiConfig config, JSONObject param)
			throws Exception {
		KeepToDb keepToDb = new KeepToDb();
		String tableName = "";
		try{
			KeepToDb.setIntoDb(param, tableName);
			KeepToDb.updateItemByItemId(KeepToDb.getDataFromTmall(tableName), tableName);
			//同步天猫库存到天猫中
			keepToDb.KeepToTmall(tableName);
			//将天猫中没有库存的先初始化库存
			keepToDb.initialToTmall(tableName);
			
		}catch(Exception e){
			e.printStackTrace();
			return new HornResponse(false, "失败");
		}
		
		return new HornResponse(true, "成功");
	}
}
